package org.linlinjava.litemall.wx.service;

import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.core.validator.Sort;
import org.linlinjava.litemall.db.domain.LitemallRentOrderDetail;
import org.linlinjava.litemall.db.service.LitemallRentOrderDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Administrator
 */
@Service
public class WxReadingDiaryService {
    @Autowired
    private LitemallRentOrderDetailService rentOrderDetailService;

    /**
     * 查询最近读的3本书
     *
     * @param userId
     * @return
     */
    public Object recentReading(Integer userId) {
        List<LitemallRentOrderDetail> rentOrderDetails = rentOrderDetailService.queryRecentRead(userId);
        if (rentOrderDetails == null || rentOrderDetails.size() == 0) {
            return ResponseUtil.ok("没有查询到最近读过的书");
        } else {
            return ResponseUtil.okList(rentOrderDetails);
        }
    }

    public Long countRead(Integer userId) {
        return rentOrderDetailService.countMyRead(userId);
    }

}
